//
//  FZUserSettingTableViewCell.m
//  EnglishTalk
//
//  Created by CyonLeuMBP on 2017/2/21.
//  Copyright © 2017年 Feizhu Tech. All rights reserved.
//

#import "FZUserSettingTableViewCell.h"

NSString *const kFZUserSettingTableViewCell  = @"FZUserSettingTableViewCell";



@implementation FZUserSettingTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    FZStyleSheet *css = [FZStyleSheet currentStyleSheet];
    
    self.backgroundColor = self.contentView.backgroundColor = [UIColor clearColor];
    
    self.borderContentView.backgroundColor = css.color_5;
    self.borderContentView.layer.masksToBounds = YES;
    self.borderContentView.layer.cornerRadius = 5;
    
    self.titleLabel.font = css.fontOfH5;
    self.titleLabel.textColor = css.color_6;
    self.subtitleLabel.font = css.fontOfH5;
    self.subtitleLabel.textColor = css.color_7;
    self.titleLabel.text = nil;
    self.subtitleLabel.text = nil;
    
    self.centerTitleLabel.font = css.fontOfH5;
    self.centerTitleLabel.textColor = css.color_4;
    self.centerTitleLabel.hidden = YES;
    [self.settingSwitch addTarget:self action:@selector(onSettingSwitchValueChanged:) forControlEvents:UIControlEventValueChanged];
    self.titleLabel.text = @"";
    self.subtitleLabel.text = @"";
    self.centerTitleLabel.text = @"";
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setSettingSwitchHidden:(BOOL)settingSwitchHidden {
    _settingSwitchHidden = settingSwitchHidden;
    self.settingSwitch.hidden = settingSwitchHidden;
}

- (void)setTitleTextAlignCenter:(BOOL)titleTextAlignCenter {
    _titleTextAlignCenter = titleTextAlignCenter;
    
    if (titleTextAlignCenter) {
        self.centerTitleLabel.hidden = NO;
        self.titleLabel.hidden = YES;
        self.subtitleLabel.hidden = YES;
        self.borderContentView.backgroundColor = [FZStyleSheet currentStyleSheet].color_10;
        self.borderContentView.layer.cornerRadius = 25;
    } else {
        self.centerTitleLabel.hidden = YES;
        self.titleLabel.hidden = NO;
        self.subtitleLabel.hidden = NO;
        self.borderContentView.backgroundColor = [FZStyleSheet currentStyleSheet].color_5;
        self.borderContentView.layer.cornerRadius = 5;
    }
    
}

- (void)onSettingSwitchValueChanged:(UISwitch *)settingSwitch {
    if (self.touchSettingSwitch) {
        self.touchSettingSwitch(settingSwitch.on);
    }
}

- (void)updateCellInfo:(FZUserSettingModel *)model {
    self.model = model;
    
    self.titleLabel.text = model.title;
    self.centerTitleLabel.text = model.title;
    if (model.subtitle && [model.subtitle length] > 0) {
        self.subtitleLabel.text = model.subtitle;
    }
    
//    if ([model.showDetail integerValue] == 1) {
////        self.selectionStyle = UITableViewCellSelectionStyleDefault;
//        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//    } else {
////        self.selectionStyle = UITableViewCellSelectionStyleNone;
//        self.accessoryType = UITableViewCellAccessoryNone;
//    }
    
}
@end
